/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.Set;

/**
 *
 * @author xgzheng
 */
public class Sell implements TableInterface{
    private int sId;
    private int sStutus;
    private double sTotalPrice;
    private double payed;
    private double price;
    private String quantity;
    private String pname;
    private Date sDate;
    private Guest sGuest;
    private Set<SellItem> sSellItem;

    public Date getsDate() {
        return sDate;
    }

    public void setsDate(Date sDate) {
        this.sDate = sDate;
    }

    public Guest getsGuest() {
        return sGuest;
    }

    public void setsGuest(Guest sGuest) {
        this.sGuest = sGuest;
    }

    public int getsId() {
        return sId;
    }

    public void setsId(int sId) {
        this.sId = sId;
    }

    public Set<SellItem> getsSellItem() {
        return sSellItem;
    }

    public void setsSellItem(Set<SellItem> sSellItem) {
        this.sSellItem = sSellItem;
    }

    public int getsStutus() {
        return sStutus;
    }

    public void setsStutus(int sStutus) {
        this.sStutus = sStutus;
    }

    public double getsTotalPrice() {
        return sTotalPrice;
    }

    public void setsTotalPrice(double sTotalPrice) {
        this.sTotalPrice = sTotalPrice;
    }

    public void insert(PreparedStatement pstmt) throws SQLException {
        pstmt.setInt(1, sId);
        pstmt.setInt(2, sStutus);
        pstmt.setDouble(3, sTotalPrice);
        pstmt.setDate(4, new java.sql.Date(sDate.getTime()));
        pstmt.setInt(5, sGuest.getgId());
        pstmt.setDouble(6, payed);
        pstmt.setString(7, quantity);
        pstmt.setDouble(8, price);
        pstmt.setString(9, pname);
        
        pstmt.executeUpdate();
    }

    public String getTableName() {
        return "sell";
    }

    public int getTableColumnCount() {
        return 9;
    }

    public String getPrimaryKey() {
        return "sid";
    }

    public Object getObject(ResultSet resultSet) throws SQLException {
//        throw new UnsupportedOperationException("Not supported yet.");
        return null;
    }

    /**
     * @return the payed
     */
    public double getPayed() {
        return payed;
    }

    /**
     * @param payed the payed to set
     */
    public void setPayed(double payed) {
        this.payed = payed;
    }

    /**
     * @return the price
     */
    public double getPrice() {
        return price;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(double price) {
        this.price = price;
    }

    /**
     * @return the quantity
     */
    public String getQuantity() {
        return quantity;
    }

    /**
     * @param quantity the quantity to set
     */
    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }

    /**
     * @return the pname
     */
    public String getPname() {
        return pname;
    }

    /**
     * @param pname the pname to set
     */
    public void setPname(String pname) {
        this.pname = pname;
    }
    
}
